/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {结论报告概况,} from "./repView";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {AppendixPageVw} from "./AppendixPage";
import {注意事项MVS, 目录页VS,} from "../../movable/rarelyVary";
import {useItemsMapPressure} from "../../common/pressure";
import {ReportFirstPageHeadNmaNmbbm} from "../../contain/rarelyVary";
import {MaterialReviewVw} from "./MaterialReview";
import {AccessoriesVw} from "./Accessories";
import {Projects默认} from "./orcBase";
import {tail安附件, tail宏观检} from "./Regular.O-1";
import {首页设备概况Sphe} from "./rarelyVary";
import {DrawingsExplanVw} from "../../boiler/power/DrawingsExplan";
import {结论报告盖章} from "./Conclusion";
import {MacroscopicVw} from "./Macroscopic";

export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [renderThickm]= useSubRepMain("cm/thickm", {nestMd:'THICK_MS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderSpectrVs]= useSubRepMain("cm/spectrVs", {nestMd:'SPECTR_VS', orc, repId:repId!, rep, NestMbVer:1});
    const [rootMenu]=useRepMenuDirItems(Projects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderUtrSonic]= useSubRepMain("cm/sonic", {nestMd:'SONIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderRadioTs ]= useSubRepMain("cm/radio", {nestMd:'RADIO_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [permeation ]= useSubRepMain("cm/permeation", {nestMd:'PERME_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [magnetic ]= useSubRepMain("cm/magnetic", {nestMd:'MAGNT_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [hardness ]= useSubRepMain("cm/hardness", {nestMd:'HARD_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [gasproof ]= useSubRepMain("cm/gasproof", {nestMd:'GASPR_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderTofd]= useSubRepMain("cm/tofd", {nestMd:'TOFD_TS', orc, repId:repId!, rep, NestMbVer:1});
    const [renderPressure]= useSubRepMain("cm/pressure", {nestMd:'PRSRE_TS', orc, repId:repId!, rep, NestMbVer:1});
    //Hash路由 定位不能精确到位： 和THICK_MS壁厚测定报告:位置示图：图片录入的相关， 图片影响hash路程?
  return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
            <div css={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'space-between',
                "@media print": {height: '100vh', pageBreakInside: 'avoid',}
            }}>
                {ReportFirstPageHeadNmaNmbbm({theme, rep })}
                <div>
                    <Text variant="h3" css={{textAlign: 'center', "@media (min-width:690px),print and (min-width:538px)": {fontSize: theme.fontSizes[6],}}}>
                      球形储罐定期检验报告
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{textAlign: 'center',}}> （ FJB/RC 1021-0-2022 ）</Text>
                </div>
                <div>
                    {首页设备概况Sphe({theme, orc, rep})}
                </div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
            </div>
            {注意事项MVS({
                rep,
                comply: '书为依据《固定式压力容器安全技术监察规程》（TSG 21-2016）制定，适用于球形储罐定期检验报告的结论报告，检验结论仅代表该设备在检验时的安全状况'
            })}

            {目录页VS({theme, orc, rep, suffix: false})}
            {结论报告概况({theme, orc, rep})}
            {结论报告盖章({theme, orc, rep})}
            {mapFxian.get('检验结论报告附页')?.do &&
                <AppendixPageVw  orc={orc} rep={rep}/>
            }
            {MaterialReviewVw({theme, orc, rep})}
            <MacroscopicVw  orc={orc} rep={rep} children={tail宏观检}/>
            {mapFxian.get('壁厚测定报告')?.do && renderThickm}
            {mapFxian.get('强度校核报告')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('射线检测报告')?.do &&  renderRadioTs}
            {mapFxian.get('超声检测报告')?.do && renderUtrSonic}

            {mapFxian.get('衍射时差法超声检测报告')?.do &&  renderTofd }
            {mapFxian.get('磁粉检测报告')?.do && magnetic}
            {mapFxian.get('渗透检测报告')?.do && permeation}
            {mapFxian.get('声发射检测报告')?.do && <h2>模板还未做的分项</h2>}

            {mapFxian.get('光谱分析报告')?.do &&  renderSpectrVs}
            {mapFxian.get('硬度检测报告')?.do && hardness}
            {mapFxian.get('金相分析报告')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('安全附件检验')?.do &&
                AccessoriesVw({theme, orc, rep,  children:tail安附件 })
            }

            {mapFxian.get('耐压试验报告')?.do && renderPressure}
            {mapFxian.get('气密性试验报告')?.do && gasproof}
            {mapFxian.get('氨检漏试验报告')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('氦、卤素检漏')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('球罐排版图')?.do && <DrawingsExplanVw orc={orc} rep={rep} table='附页图' reserve='6.5rem' title={'球罐排版附页图'}/>}
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
